package pl.edu.agh.gronoMining.frequentSubgraphFinder.frequentSearcher.subgraph.impl;

import pl.edu.agh.gronoMining.frequentSubgraphFinder.frequentSearcher.subgraph.SubgraphMove;
import pl.edu.agh.gronoMining.frequentSubgraphFinder.graph.Node;

public class SubgraphMoveImpl implements SubgraphMove {
	
	private int type;
	private int fromNodeId;
	private int toNode;
	private int additionalArg;
	private boolean isCreatingPath;
	private boolean wasPath;
	private Node orgToNode = null;
	
	public SubgraphMoveImpl(int type, int fromNodeId, int toNode, int additionalArg, boolean isCreatingPath, boolean wasPath) {
		this.type = type;
		this.fromNodeId = fromNodeId;
		this.toNode = toNode;
		this.additionalArg = additionalArg;
		this.isCreatingPath = isCreatingPath;
		this.wasPath = wasPath;
	}
	
	public int getType() {
		return type;
	}
	
	public int getFromNodeId() {
		return fromNodeId;
	}
	
	public int getToNode() {
		return toNode;
	}
	
	public int getAdditionalArg() {
		return additionalArg;
	}
	
	public void setOrgToNode(Node toNode) {
		this.orgToNode = toNode;
	}
	
	public Node getOrgToNode() {
		return this.orgToNode;
	}
	
	public boolean isCreatingPath() {
		return isCreatingPath;
	}
	
	public boolean wasPath() {
		return wasPath;
	}
	
	public boolean equals(Object o) {
		SubgraphMove move = (SubgraphMove) o;
		if (move.getType() != this.type)
			return false;
		if (move.getFromNodeId() != this.fromNodeId)
			return false;
		if (move.getToNode() != this.toNode)
			return false;
		if (move.isCreatingPath() != this.isCreatingPath)
			return false;
		if (move.wasPath() != this.wasPath)
			return false;
		return true;
	}
	
	public int hashCode() {
		return new Integer(this.fromNodeId).hashCode() + new Integer(this.toNode).hashCode();
	}
	
	public String toString() {
		if (this.orgToNode!= null)
			return "move - "+type+", from "+fromNodeId+", to "+toNode+"("+this.orgToNode.getId()+"), isCreatingPath "+isCreatingPath;
		return "move - "+type+", from "+fromNodeId+", to "+toNode+", isCreatingPath "+isCreatingPath;
	}
}
